<?php
defined( '_VALID_MOS' ) or die('<script>window.location.href="http://www.kinifurniture.com";</script>');
$adm_functions->is_admin_login();

$adm_functions->is_admin_login();

$icon_description='
<table><tr><td>
	<table cellspacing="0" cellpadding="4" border="0" align="center">
		<tr align="center">
			<td>
				<img src="show_files/publish1.png" border="0" alt="Pending" />
			</td>
			<td>
				Agenda is <u>inactive</u> |
			</td>
			<td>
				<img src="show_files/tick.png" border="0" alt="Visible" />
			</td>
			<td>
				Agenda is <u>active</u>  |
			</td>
			<td>
				<img src="show_files/delete.png" border="0" alt="Visible" />
			</td>
			<td>
				<u>Delete</u> agenda
			</td>
		</tr>
	</table>
</td></tr><tr><td align="center">
	<table cellspacing="0" cellpadding="4" border="0" align="center">
		<tr align="center">
			<td align="center">
				<i>Click on icon to toggle state or execute command.</i>
			</td>
		</tr>
	</table>
</td></tr></table>
';
$adm_menu='
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
<tr>
	<td class="menudottedline" width="40%">
		<div class="pathway"><img border="0" src="assets/admin/'.$SITE_LOGO_ADMIN.'"/></div>	</td>
	<td class="menudottedline" align="right">
				<table cellpadding="0" cellspacing="0" border="0" id="toolbar">
		<tr valign="middle" align="center">
				<td>&nbsp;</td>
				<td>
					<a class="toolbar" href="admin.php?show=index">
					<img src="show_files/home.png" alt="Home" name="home" title="Home" align="middle" border="0" />				<br />Home</a>
				</td>
					<td>&nbsp;</td>
					<td>
			<a class="toolbar" href="admin.php?show=add_agenda">
				<img src="show_files/new_f200.png"  alt="New" name="new" title="New" align="middle" border="0" />				<br />New</a>
		</td>
				</tr>
		</table>
			</td>
</tr>
</table>

<br />
';

if($action=="do_delete"){
	$dbh->query("delete from news where id=$id");
	echo '<script>window.location.href="admin.php?show=agenda_manager";</script>';
}
if($action=="do_active"){
	$dbh->query("update news set status='Y' where id=$id");
	echo '<script>window.location.href="admin.php?show=agenda_manager";</script>';
}
if($action=="do_inactive"){
	$dbh->query("update news set status='N' where id=$id");
	echo '<script>window.location.href="admin.php?show=agenda_manager";</script>';
}

if($action=="") $action="list";

if($action=="list"){

if(!$page_no)
	$page_no=1;
$MAX=10;
$lastrow=$MAX+$page_no;
if(!next_page)
	$next_page=1;
$next_page=$next_page+1;

$imgSr=$page_no;

if(!$sort)
$sort='all';

if($sort=='all')
{
	$condition="";
	$section='All';
	$selected1='selected';
}

if($sort=='active')
{
	$condition=" and status='Y'";
	$section='Active Agenda';
	$selected2='selected';
}

if($sort=='inactive')
{
	$condition=" and status='N'";
	$section='Inactive Agenda';
	$selected3='selected';
}

	$sort_agenda='	
<select name="sort" class="inputbox" size="1" onchange="document.adminForm.submit();">
                 <option value="all" '.$selected1.'>All</option>
                 <option value="active" '.$selected2.'>Active Agenda</option>
                 <option value="inactive" '.$selected3.'>Inactive Agenda</option>
                </select>
';
		
	$qry="select * from news where news_type='A' $condition order by entrydate desc";
	$lim_min = ($page_no-1)*$MAX;
	$qry2="$qry limit $lim_min,$MAX"; 
	$select=$dbh->query($qry2);
	$TOTAL_RECORDSET=$dbh->num_rows($dbh->query($qry));

	$agenda_list='';
	$nomor_urut=(($page_no-1)*$MAX);
	while($sqlRow=mysql_fetch_object($select))
	{
	$nomor_urut++;
	$news_id=$sqlRow->id;
	$news_date=$sqlRow->entrydate;
	$news_title=$sqlRow->title;
	$news_url=$sqlRow->url;
	if ($sqlRow->status=='Y') 
			$urlactive="<a href='admin.php?show=agenda_manager&action=do_inactive&id=$news_id'><img border='0' src='show_files/tick.png' /></a>";
		else 
			$urlactive="<a href='admin.php?show=agenda_manager&action=do_active&id=$news_id'><img border='0' src='show_files/publish1.png' /></a>";
	$agenda_list.='
		<tr class="row0">
			<td align="center">
				'.$nomor_urut.'
			</td>
			<td>
				<a href="admin.php?show=edit_agenda&id='.$news_id.'" title="Edit Content">'.$news_title.'</a>
			</td>
			<td align="center">
				'.$urlactive.'
			</td>
			<td align="center">
				<a href="admin.php?show=agenda_manager&action=do_delete&id='.$news_id.'" onclick="return confirm(\'Do you want to delete?\');"><img border="0" src="show_files/acc_del.png" /></a>
			</td>
			<td align="left">
				'.$news_date.'
			</td>
			<td>
				'.$news_url.'
			</td>
		</tr>
	';
	}

//	$select=$dbh->query("select user_id from anggota where username='$username'");
//	$sqlRow=mysql_fetch_object($select);
	
		
	//pagination settings
//	if(!$page_no) $page_no=0;
//	$start=($page_no * $MAX);
	
////////////////////////////////////////////Pagination////////////////////////////////
//$sql="select * from anggota $condition order by user_id desc";
//$sqlResult=$dbh->query($sql);
//$TOTAL_RECORDSET=$dbh->num_rows();

//$i=1;
//$no_of_pages = ceil($TOTAL_RECORDSET / $MAX);
//if($no_of_pages>1)
//	{
//	$pagination="Go Page :<select name='page_no' onChange='this.form.submit();'>";
//	while($i<=$no_of_pages){ $j=$i-1;
//		$page_no==$j?$pagination.="<option value='$j' selected>$i</option>":$pagination.="<option value='$j'>$i</option>";
//		$i++;
//	}
//	$pagination.="</select>";
//}
//else 
//	$pagination="";
}

//=====================Starting Pagination From Here==========================
	
	//global $my_page_name;
	$my_page_name="./admin.php?show=agenda_manager&sort=".$sort;
	include("admin_pagination.inc");

?>